<?php

class Api_Controller extends Xenforo_Controller
{
	public function responseNoPermission()
	{
		return $this->responseError(new XenForo_Phrase('do_not_have_permission'), 403);
	}
	
	protected function _checkCsrf($action)
	{
	}
	
	protected function _handlePost($action)
	{
	}
	
	protected function _getPublicSession()
	{
		$session = new XenForo_Session();

		$session->start($this->_request->getParam('sessionid'), ip2long($this->_request->getParam('ipaddress')));
		
		if (!$session->sessionExists())
		{
			$cookiePrefix = XenForo_Application::get('config')->cookie->prefix;

			$userCookie = $this->_request->getParam('sessionuser');
			
			if ($userCookie)
			{
				$userModel = $this->getModelFromCache('XenForo_Model_User');
				
				if ($userId = $userModel->loginUserByRememberCookie($userCookie))
				{
					$session->changeUserId($userId);
				}
				else
				{
					XenForo_Helper_Cookie::deleteCookie('user', true);
				}
			}
		}

		return $session;
	}
}